//
//  CommonDialogFunctions.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/8/31.
//

import Foundation
import AVFoundation
import SwiftUI


//提示弹窗
func showTipsDialog(text: String, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonTipDialogView(title: "温馨提示", text: text, alignment: alignment) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗-按钮
func showBtnDialog(text: String, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonBtnDialogView(title: "温馨提示", text: text, btn: "确定", alignment: alignment, dismissCancel: {
            dismiss()
        }) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗
func showTipsDialog(title : String, text: String, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonTipDialogView(title: title, text: text, alignment: alignment) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗
func showTipsDialog(title : String, text: AttributedString, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonTip2DialogView(title: title, text: text, alignment: alignment) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗-按钮
func showBtnDialog(title : String, text: String, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonBtnDialogView(title: title, text: text, btn: "确定", alignment: alignment, dismissCancel: {
            dismiss()
        }) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗
func showTipsDialog(text: String, alignment: TextAlignment = .center) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonTipDialogView(title: "温馨提示", text: text, alignment: alignment){
            dismiss()
        }
    }
}

//提示弹窗-按钮
func showBtnDialog(text: String, alignment: TextAlignment = .center) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonBtnDialogView(title: "温馨提示", text: text, btn: "确定", alignment: alignment, dismissCancel: {
            dismiss()
        }) {
            dismiss()
        }
    }
}

//提示弹窗
func showTipsDialog(text: String, btn: String, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonTipDialogView(title: "温馨提示", text: text, alignment: alignment) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗-按钮
func showBtnDialog(text: String, btn: String, alignment: TextAlignment = .center, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonBtnDialogView(title: "温馨提示", text: text, btn: btn, alignment: alignment, dismissCancel: {
            dismiss()
        }) {
            dismiss()
            dismissInvoke()
        }
    }
}

//提示弹窗
func showEditDialog(title: String, hint: String, content:String, dismissInvoke: @escaping (String?) -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonEditDialogView(title: title,hint: hint, content: content, uiImage: nil, allowEmpty: false) { it in
            dismiss()
            dismissInvoke(it)
        } dismissCancel: {
            dismiss()
            dismissInvoke(nil)
        }
    }
}

//提示弹窗 (允许为空)
func showEditDialogAllowEmpty(title: String, hint: String, content:String, dismissInvoke: @escaping (String) -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonEditDialogView(title: title,hint: hint, content: content, uiImage: nil, allowEmpty : true) { it in
            dismiss()
            dismissInvoke(it)
        } dismissCancel: {
            dismiss()
        }
    }
}

//提示弹窗
func showEditDialog(title: String, hint: String, content:String,uiImage: UIImage, dismissInvoke: @escaping (String) -> Void) {
    SwiftEntryKitWrapper.showContentPopup { dismiss in
        CommonEditDialogView(title: title,hint: hint, content: content, uiImage: uiImage, allowEmpty: false) { it in
            dismiss()
            dismissInvoke(it)
        } dismissCancel: {
            dismiss()
        }
    }
}

//版本提示弹窗
func showVersionTipsDialog(text: String, btn: String, dismissInvoke: @escaping () -> Void) {
    SwiftEntryKitWrapper.showBottomPopup { dismiss in
        VersionTipsDIalogView(text: text, btn: btn) {
            dismiss()
            dismissInvoke()
        }
    }
}
